package net.microfigure.service.impl;

import net.microfigure.model.Family;
import net.microfigure.model.ZcPolicy;
import net.microfigure.model.Family;
import net.microfigure.commons.result.PageInfo;
import net.microfigure.mapper.FamilyMapper;
import net.microfigure.service.IFamilyService;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 家庭表 服务实现类
 * </p>
 *
 * @author 林景锋
 * @since 2018-06-15
 */
@Service
public class FamilyServiceImpl extends ServiceImpl<FamilyMapper, Family> implements IFamilyService {
	@Autowired
	private FamilyMapper familyMapper;
	
	@Override
	public void selectDataGrid(PageInfo pageInfo,String name) {
		Page<Family> page = new Page<Family>(pageInfo.getNowpage(), pageInfo.getSize());
		EntityWrapper<Family> wrapper = new EntityWrapper<Family>();
//		String name = "admin";
		String areaNo = familyMapper.selectListcodeByname(name);
		System.out.println("输出当前"+areaNo);
		wrapper.where("area_no = {0}",areaNo);
		wrapper.orderBy(pageInfo.getSort(),pageInfo.getOrder().equalsIgnoreCase("ASC"));
		selectPage(page,wrapper);
		pageInfo.setRows(page.getRecords());
		pageInfo.setTotal(page.getTotal());
		
		
	}
	
public List<Family> selectAll(){
		
		EntityWrapper<Family> wrapper = new EntityWrapper<Family>();
		wrapper.orderBy("seq");
		return familyMapper.selectList(wrapper);
		
		
		
	}
}
